package com.capacitydorm.server.service;

import com.capacitydorm.server.dao.FloorMapper;
import com.capacitydorm.server.domain.Floor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class FloorService {

    @Resource
    private FloorMapper floorMapper;


    public List<Floor> selectAll(Integer tid) {
        Example example = new Example(Floor.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("towerId",tid);
        return floorMapper.selectByExample(example);
    }

    public void add(Floor floor) {
        floorMapper.insert(floor);
    }

    public void delete(Integer id) {
        floorMapper.deleteByPrimaryKey(id);
    }

    public void update(Integer id, Floor floor) {
        floor.setId(id);
        floorMapper.updateByPrimaryKey(floor);
    }

    public List<Floor> check(Floor floor) {
        return floorMapper.select(floor);
    }
}
